
package com.hexinfo.dmpro.sparing.service.impl;

import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hexinfo.dmpro.common.utils.CommonConstants;
import com.hexinfo.dmpro.common.utils.StringUtils;
import com.hexinfo.dmpro.sparing.model.UatSyncLogs;
import com.hexinfo.dmpro.sparing.dao.UatSyncLogsMapper;
import com.hexinfo.dmpro.sparing.service.UatSyncLogsService;
import org.springframework.stereotype.Service;

/**
 * UAT同步日志表
 *
 * @author yemw
 * @date 2023-11-20 18:24:56
 */
@Service
public class UatSyncLogsServiceImpl extends ServiceImpl<UatSyncLogsMapper, UatSyncLogs> implements UatSyncLogsService {

    @Override
    public Page queryList(Page page, UatSyncLogs uatSyncLogs) {
        LambdaQueryWrapper<UatSyncLogs> wrapper = Wrappers.lambdaQuery();
        wrapper.eq(StrUtil.isNotBlank(uatSyncLogs.getTaskId()),UatSyncLogs::getTaskId,uatSyncLogs.getTaskId())
                .like(StrUtil.isNotBlank(uatSyncLogs.getSourceName()),UatSyncLogs::getSourceName,uatSyncLogs.getSourceName())
                .like(StrUtil.isNotBlank(uatSyncLogs.getLibraryTableName()),UatSyncLogs::getLibraryTableName, StringUtils.toLowerCase(uatSyncLogs.getLibraryTableName()))
                .eq(StrUtil.isNotBlank(uatSyncLogs.getStandbyTime()),UatSyncLogs::getStandbyTime,uatSyncLogs.getStandbyTime())
                .eq(StrUtil.isNotBlank(uatSyncLogs.getTaskState()),UatSyncLogs::getTaskState,uatSyncLogs.getTaskState())
                .eq(UatSyncLogs::getDel,CommonConstants.STATUS_NORMAL).orderByDesc(UatSyncLogs::getCreateTime);
        Page returnPage = this.baseMapper.selectPage(page, wrapper);
        return returnPage;
    }
}
